<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.jxLC.Action.*"%>
<%@ page language="java" import="com.jxLC.Model.*" %>
<%@ page language="java" import="com.jxLC.Service.*" %>
<%@ page import="com.jxLC.util.*"%>
<%@include file="/checkLoginSession.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
ContentService cs =new ContentService();
FilesService filesService=new FilesService();
TopicService topicService = new TopicService();
int type = request.getParameter("type") == null ? -1 : Integer.parseInt(request.getParameter("type"));
String cname = request.getParameter("cname");
List<Content> fc = cs.getContent(type,cname);
Map topicMap = topicService.getTopicMap();
%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>:::江西低碳-管理员后台:::</title>
	<link href="/mycss/my.css"  rel="stylesheet" type="text/css" />
	<link href="/mycss/details.css"  rel="stylesheet" type="text/css" />
	<link href="/mycss/cm.css"  rel="stylesheet" type="text/css" />
	<script type="text/javascript" charset="utf-8" src="/kindeditor/kindeditor.js"></script>
	<script type="text/javascript" src="/myjs/my.js"></script>
    <script type="text/javascript" src="/myjs/jquery-1.4.2.min.js"></script>
	<style type="text/css">
	 
    </style>
    <script type="text/javascript">

       window.onload=function()
    { 
        var result1 ="<%=request.getAttribute("Dosuccess")%>";
        var result2 ="<%=request.getAttribute("dodelete")%>";
        var result3 ="<%=request.getAttribute("viewmsg")%>";
        
        if(result1!='null'  &&  result1!=undefined)
       {
           alert(result1);
       }  
        if(result2!='null'  &&  result2!=undefined)
       {
           alert(result2);
       }  
        if(result3!='null'  &&  result3!=undefined)
       {
           alert(result3);
       }
    }
   function down(id){
	   if(id.indexOf('_')!=-1){
			var index=   id.indexOf('_');
			var vid=id.substring(index+1);
			var me =document.getElementById("hidden_"+vid).value;
			var down =document.getElementById("hidden_"+ (vid - (-1))) == null ? "" : document.getElementById("hidden_"+ (vid - (-1))).value;

			var strMsg = me+"-"+down ;
			window.location.href="moveContentAction.action?ud=D&strMsg="+strMsg;

		}
	   }

   function up(id){
	   if(id.indexOf('_')!=-1){
			var index=   id.indexOf('_');
			var vid=id.substring(index+1);
			var last= document.getElementById("hidden_"+(vid-1)) == null ? "" : document.getElementById("hidden_"+(vid-1)).value;
			var me =document.getElementById("hidden_"+vid).value;

			var strMsg = last+"-"+me ;
			window.location.href="moveContentAction.action?ud=U&strMsg="+strMsg;

		}
	   }
       
	</script>
  </head>
  
 <body style="background-color:#EBFCF3">
    <s:include value="/admin/header.jsp"></s:include>
	<center><div id="m" >
       <s:include value="/admin/left.jsp"></s:include>
       <div id="mc">
          <div id="mc1"></div>
          <div id="mc2">
           <h4 align="left"><img  src="/my.photo/photo/to.gif"><font style="color:black;font-family: 仿宋 ;font-weight: bold;">当前用户：</font><font style="color:blue;font-family: 仿宋 ;font-weight: bold;">管理员</font></h4>
           <h4 align="left"><img  src="/my.photo/photo/to.gif"><font style="color:black;font-family: 仿宋 ;font-weight: bold;">当前位置：</font><font style="color:blue;font-family: 仿宋 ;font-weight: bold;">上传文件列表</font></h4>
           <h4 align="left"><img  src="/my.photo/photo/to.gif"><font style="color:black;font-family: 仿宋 ;font-weight: bold;">操作：</font><font style="color:blue;font-family: 仿宋 ;font-weight: bold;"><a href="contentup.jsp">上传文件</a></font></h4>
          </div>
          <div id="mc3">
          	<form action="/admin/content_list.jsp" >
           		主题：<input type="text" name="cname" value="<%=cname %>">
           		类型：<select name="type">
           				<option value="-1" <%if(type == -1){%> selected="selected"<% } %> >==请选择==</option>
           				<option value="1" <%if(type == 1){%> selected="selected"<% } %> >新闻</option>
           				<option value="2" <%if(type == 2){%> selected="selected"<% } %> >展会动态</option>
           				<option value="3" <%if(type == 3){%> selected="selected"<% } %> >前沿技术</option>
           				<option value="4" <%if(type == 4){%> selected="selected"<% } %> >江西低碳</option>
           				<option value="5" <%if(type == 5){%> selected="selected"<% } %> >科普知识</option>
           				<option value="6" <%if(type == 6){%> selected="selected"<% } %> >低碳政策</option>
           		      </select>
           		      <input type="submit" value="查询">
           </form>
           <div style="margin-top: 20px"><font style="font-size:15px;font-weight: bold">文件列表</font>	</div>
           <table width="700" style="margin-top:10px;margin-bottom:20px;">
             <tr height="30">
               <th width="5%">编号</th> <th width="10%">类型</th> <th width="40%">主题</th><th width="5%">点击量</th><th width="10%">上传时间</th> <th width="30%">操作</th>
             </tr>
             
             <%
            int pageSize=10;             //每页显示条数
            int recordCount=fc.size();  //总记录数
            int currentPage=1;          //当前页
            String currentPageStr=request.getParameter("page");
            if(currentPageStr !=null){
            currentPage=Integer.parseInt(currentPageStr);
            }
            PageUtil pageUtil =new PageUtil(pageSize,recordCount,currentPage);
            int  j;
            String flags="";
            j=(currentPage-1)*8+1;
            for(int i=pageUtil.getFromIndex();i<pageUtil.getToIndex();i++){
        	 Content content=fc.get(i);
        	 
             %>
          <tr >
          <td height="35" align="center" ><font style="font-size: 13px;"><%=j%></font></td>
          <td align="center" ><font style="font-size: 13px;"><%=topicMap.get(content.getCTopic_ID()) %>
          <input type="hidden" value="<%=content.getCContent_ID()%>_<%=content.getCissue() %>" id="hidden_<%=j%>"/></font></td>
          <td align="center"><font style="font-size: 13px;"><%=content.getCContent_topic() %></font></td>
          <td  align="center"><font style="font-size: 13px;"><%=content.getCctimes() %></font></td>
          <td  align="center"><font style="font-size: 13px;"><%=content.getCContent_time() %></font></td>
          <td  align="center">
                    <a href="getContenttextAction.action?CContent_ID=<%=content.getCContent_ID() %>" target="_blank">预览</a> || 
                    <a href="getContentAction.action?CContent_ID=<%=content.getCContent_ID() %>" target="_self">修改</a> || 
                    <a href="contentdel.action?CContent_ID=<%=content.getCContent_ID() %>" onclick="return confirm('确定要删除吗？')">删除</a> ||
                    <a id ="up_<%=j%>" href="#" onclick="up(this.id)">上移</a> || 
                    <a id="down_<%=j%>" href="#" onclick="down(this.id)">下移</a>
           
          </td>
          </tr>
             <%
             j++;
              }
             %>
               <tr>
       <td colspan="10" height="40"   align="center">
           <font style="font-size: 14px;"> 记录总数<%=recordCount %>条   每页显示<%=pageSize %>条   当前页/总页数  <%=pageUtil.getCurrentPage() %>/<%=pageUtil.getPageCount() %>
           <a href="content_list.jsp?page=1">首页</a>  
           <a href="content_list.jsp?page=<%=pageUtil.getPrevPage() %>">上页 </a>|       
           <a href="content_list.jsp?page=<%=pageUtil.getNextPage() %>">下页 </a>|
           <a href="content_list.jsp?page=<%=pageUtil.getPageCount() %>">末页 </a>
              跳到<input type="text" size="3" id="newPage">页 </font>
        <input type="button"  value="GO" onclick="processGoPage()" > 
           <script type="text/javascript">
				function processGoPage() {
			    var newPage = document.getElementById("newPage").value;
	            var reg = /\d+$/;	
	            if(!newPage.match(reg))	{
				alert('页面格式不合法');
				document.getElementById("newPage").focus();
				}
				else{
				window.location.href="choicefile.jsp?page="+newPage}
				}
          </script>
     </td>
  </tr>
             </table>
          </div>
       </div>
	</div></center>
	<s:include value="/admin/tail.jsp"></s:include>
</body>
</html>
